Skip to content

Fix Android dirs raising opaque TypeError when the app storage folder is undetectable - #547

Open
Str0k wants to merge 2 commits into
tox-dev:mainfrom
Str0k:githubpower/t_1ee7f961
Open

Fix Android dirs raising opaque TypeError when the app storage folder is undetectable#547
Str0k wants to merge 2 commits into
tox-dev:mainfrom
Str0k:githubpower/t_1ee7f961

Conversation

@Str0k

@Str0k Str0k commented Sep 13, 2026

Copy link
Copy Markdown

On Android, when the private app storage folder cannot be detected (no python4android, no pyjnius, and no recognizable /data/.../files entry on sys.path), every Android directory property (user_data_dir, user_config_dir, user_cache_dir, user_bin_dir, etc.) crashed with TypeError: expected str, bytes or os.PathLike object, not NoneType. The _android_folder() helper is documented to return str | None when detection fails, but each consumer blindly cast the result to str and passed it to path joining. After this fix, these properties raise a descriptive RuntimeError explaining that the base Android app folder cannot be determined, matching the repo's existing error style in unix.py.

The documented contract of _android_folder() allows None, so callers deserve an actionable error (or a catchable RuntimeError to fall back to another implementation) rather than an opaque TypeError from deep inside os.path.join. A new helper _require_android_folder() centralizes the None check with a clear message, and the four affected properties now use it. Implementation reason: minimal, no API signature change; the RuntimeError-with-msg pattern follows the existing unix.py precedent.

Validation:

  • Regression on unchanged base: 17 assertion failure(s); with patch: 18 tests, exit 0.
  • Full suite: base 1353 tests (exit 1); patch 1353 tests (exit 1).
  • 105 existing failures remain; no new failing cases were detected.

AI assistance: implementation and independent review used Hermes with GLM 5.3. Test evidence was reproduced in clean checkouts. This does not represent a human review.
An additional model reviewed the supplied patch and evidence without executing tools.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant